<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="js/jquery-1.11.0.js"></script>
</head>
<body>
    转出用户： <input type="text" name="outName" id="outName"> <br>
    转入用户： <input type="text" name="inName" id="inName"> <br>
    转账金额： <input type="text" name="money" id="money"> <br>

    <button id="transfer">转账</button>

    <script>
        //回显转出用户名
        let search = location.search;  // ?name=张三
        let name = search.split("=")[1];

        $("#outName").val(decodeURI(name));


        $("#transfer").click(function (){
            let inName = $("#inName").val();
            let outName = $("#outName").val();
            let money = $("#money").val();

            let data = {"inName":inName,"outName":outName,"money":money};

            $.ajax({
                url:"/account/transfer",
                type:"post",
                data:JSON.stringify(data),
                contentType:"application/json",
                success:function (r){
                    let code = r.code;
                    if (code == 200){
                        //转账成功 -- 跳转到首页
                        location.href = "index.html"
                    }else{
                        //转账失败 -- 提示用户
                        alert(r.msg)
                    }
                },
                dataType:"json"
            })
        });
    </script>
</body>
</html>